<?php
class keu_kas_bank_detail_model extends MY_Model {
	var $model = 'keu_kas_bank_detail';
	
	function GetJSON()
	{
		$ls_sql	= "	SELECT	td.*, 
							coa.nama_coa, cc.nama_cost_center
					FROM	keu_trans_kas_bank_detail td
							INNER JOIN	keu_coa coa ON coa.id_coa = td.id_coa
							INNER JOIN sw_cost_center cc ON cc.id_cost_center_pk = td.kd_cost_center
					WHERE	td.id_dok = '".post('id_dok')."'
					ORDER BY ".(post('sort')=='' ? 'td.id_dok' : post('sort'))." ".(post('order')=='' ? 'asc' : post('order'));
					
		return json_encode( $this->paging($ls_sql) );
	}
		
	function Add($arr_data){
		
		$this->db->insert('keu_trans_kas_bank_detail', $arr_data);
	}
	
	function Update($arr_data, $arr_rule){
		$this->db->update('keu_trans_kas_bank_detail', $arr_data, $arr_rule);
	}
	
	
	function DeleteSingle($as_id_dok, $as_cost_center, $as_coa)
	{
		try {
			$this->db->delete('keu_trans_kas_bank_detail', array('id_dok' => $as_id_dok, 
														'kd_cost_center' => $as_cost_center,
														'id_coa' => $as_coa));
			return '';
		} catch(Exception $e) {
			return $e->getMessage();
		}
	}
}
?>